package Controller;

import Model.Grid;
import Views.CircleView;
import Views.RectangleView;
import java.awt.Color;
import javax.swing.JOptionPane;

public abstract class Controller
{
    protected Grid model;
    protected CircleView circleView;
    protected RectangleView rectangleView;
    
    
    public Controller(Grid model, CircleView circleView, RectangleView rectangleView)
    {
        this.model = model;
        this.circleView = circleView;
        this.rectangleView = rectangleView;
    }    
    
    public boolean isMoveAuthorized(int x, int y)
    {
        if(x < 0 || y < 0 || x>=model.getSize() || y>=model.getSize())
        {
            return false;
        }
        
        for (int i= 0;i<model.getByStanders().size();i++)
        {
            if(x == model.getByStanders().get(i).getI() &&
                    y == model.getByStanders().get(i).getJ())
            {
               JOptionPane.showMessageDialog(circleView, "Déplacement non autorisé :"
                       + "la case est occupée");
               return false;
            }
        }
        return true;
    }
    
}
